﻿using System;
using System.Threading.Tasks;
using Microsoft.Owin;
using Owin;
using System.Web.Http;
using Owin;
using Swashbuckle.Application;
using System.Net.Http.Formatting;

[assembly: OwinStartup(typeof(LabelPrint.Startup))]

namespace LabelPrint
{
    public class Startup
    {
        public void Configuration(IAppBuilder appBuilder)
        {
            HttpConfiguration config = new HttpConfiguration();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                 routeTemplate: "api/{controller}/{action}/{id}",//{action}目的是为了一个Controller能有多个Get Post方法
                defaults: new { id = RouteParameter.Optional });

       
            // 有关如何配置应用程序的详细信息，请访问 http://go.microsoft.com/fwlink/?LinkID=316888
            config
           .EnableSwagger(c => c.SingleApiVersion("v1", "A title for your API"))
           .EnableSwaggerUi();
            //清除xml格式，使用json格式
            config.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
            config.Formatters.Add(new JsonMediaTypeFormatter());

            //将路有配置附加到appBuilder
            appBuilder.UseWebApi(config);
        }
    }
}
